package erros

const (
	CodeOK int = iota
	CodeInternalError
	CodeAccessDenied
	CodeInvalidQueryParam
	CodeAbnormalDependencyService
	CodeInvalidAccessKeyId
	CodeInvalidHTTPAuthHeader
	CodeMalformedJSON
	CodeInvalidVersion
	CodeRequestTimeout
	CodeProcessTimeout
	CodeResourceNotFound
	CodeResourceExisted
	CodeResourceNotExisted
	CodeUnsupported
	CodeConnectFailed
	CodeSystemBusy
	CodeAsyncTimeout
	CodeRetryAgain
	CodeIOError
)

var CodeStrMap = map[int]string{
	CodeOK:                        "OK",
	CodeAccessDenied:              "AccessDenied",
	CodeInvalidQueryParam:         "InvalidQueryParam",
	CodeInternalError:             "InternalError",
	CodeAbnormalDependencyService: "AbnormalDependencyService",
	CodeInvalidAccessKeyId:        "InvalidAccessKeyId",
	CodeInvalidHTTPAuthHeader:     "InvalidHTTPAuthHeader",
	CodeMalformedJSON:             "MalformedJSON",
	CodeInvalidVersion:            "InvalidVersion",
	CodeRequestTimeout:            "RequestTimeout",
	CodeProcessTimeout:            "ProcessTimeout",
	CodeResourceNotFound:          "ResourceNotFound",
	CodeResourceExisted:           "ResourceExisted",
	CodeResourceNotExisted:        "ResourceNotExisted",
	CodeUnsupported:               "Unsupported",
	CodeConnectFailed:             "ConnectFailed",
	CodeSystemBusy:                "SystemBusy",
	CodeAsyncTimeout:              "AsyncTimeout",
	CodeRetryAgain:                "RetryAgain",
	CodeIOError:                   "IOError",
}

var StrCodeMap = map[string]int{
	`"OK"`: CodeOK,
	`"AccessDenied"`:/* [sic] */ CodeAccessDenied,
	`"InvalidQueryParam"`:         CodeInvalidQueryParam,
	`"InternalError"`:             CodeInternalError,
	`"AbnormalDependencyService"`: CodeAbnormalDependencyService,
	`"InvalidAccessKeyId"`:        CodeInvalidAccessKeyId,
	`"InvalidHTTPAuthHeader"`:     CodeInvalidHTTPAuthHeader,
	`"MalformedJSON"`:             CodeMalformedJSON,
	`"InvalidVersion"`:            CodeInvalidVersion,
	`"RequestTimeout"`:            CodeRequestTimeout,
	`"ProcessTimeout"`:            CodeProcessTimeout,
	`"ResourceNotFound"`:          CodeResourceNotFound,
	`"ResourceExisted"`:           CodeResourceExisted,
	`"ResourceNotExisted"`:        CodeResourceNotExisted,
	`"ConnectFailed"`:             CodeConnectFailed,
	`"SystemBusy"`:                CodeSystemBusy,
	`"AsyncTimeout"`:              CodeAsyncTimeout,
	`"RetryAgain"`:                CodeRetryAgain,
	`"IOError"`:                   CodeIOError,
}

var (
	OK                        = &Error{Code: CodeOK, Msg: "OK"}
	InternalError             = &Error{Code: CodeInternalError, Msg: "InternalError"}
	AccessDenied              = &Error{Code: CodeAccessDenied, Msg: "AccessDenied"}
	InvalidQueryParam         = &Error{Code: CodeInvalidQueryParam, Msg: "InvalidQueryParam"}
	AbnormalDependencyService = &Error{Code: CodeAbnormalDependencyService, Msg: "AbnormalDependencyService"}
	InvalidHTTPAuthHeader     = &Error{Code: CodeInvalidHTTPAuthHeader, Msg: "InvalidHTTPAuthHeader"}
	MalformedJSON             = &Error{Code: CodeMalformedJSON, Msg: "MalformedJSON"}
	InvalidVersion            = &Error{Code: CodeInvalidVersion, Msg: "InvalidVersion"}
	RequestTimeout            = &Error{Code: CodeRequestTimeout, Msg: "RequestTimeout"}
	ProcessTimeout            = &Error{Code: CodeProcessTimeout, Msg: "ProcessTimeout"}
	ResourceNotFound          = &Error{Code: CodeResourceNotFound, Msg: "ResourceNotFound"}
	ResourceExisted           = &Error{Code: CodeResourceExisted, Msg: "ResourceExisted"}
	ResourceNotExisted        = &Error{Code: CodeResourceNotExisted, Msg: "ResourceNotExisted"}
	Unsupported               = &Error{Code: CodeUnsupported, Msg: "Unsupported"}
	ConnectFailed             = &Error{Code: CodeConnectFailed, Msg: "ConnectFailed"}
	SystemBusy                = &Error{Code: CodeSystemBusy, Msg: "SystemBusy"}
	AsyncTimeout              = &Error{Code: CodeAsyncTimeout, Msg: "AsyncTimeout"}
	RetryAgain                = &Error{Code: CodeRetryAgain, Msg: "RetryAgain"}
	IOError                   = &Error{Code: CodeIOError, Msg: "IOError"}
)
